#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         Tody Guo

 Script Function:
	Panda LCD FW update tool.

#ce ----------------------------------------------------------------------------

; Script Start - for mutilanguage

$title="MStar TCON AUX Read/Write Tool V4.0(20161117_2)"
$tOpen="Open"
$tSave="Save As"

Func LoadBin()
   ; Begin load fw bin file
   Sleep(500)
   Send("{ALT}")
   Send("FL")
   Sleep(3500) ;waiting for save diaglog
   ;WinMenuSelectItem("[CLASS:TFormAUXEepRW]", "", "&File", "&LoadTcon(bin)")
   ControlSetText($tOpen, "", "[CLASS:Edit; INSTANCE:1]", @ScriptDir & "\" &"MST7332L_156LF1L02_Panda_THTF_SDDRS_21E57_20170118.bin")
   Sleep(700)
   ControlClick($tOpen, "", "[CLASS:Button; INSTANCE:1]")
   Sleep(700)
   ControlClick($title, "", "[CLASS:TButton; INSTANCE:5]")
   Sleep(700)
   ;  End of load fw bin File
EndFunc

Func ReadTCON()
   ControlClick($title, "", "[CLASS:TButton; INSTANCE:3]")
   Sleep(5500)
EndFunc

Func Init()
   Run ("MStar_eDP_AUX_Tooling_V4_0.exe")
   Sleep(2500)
   WinActivate($title)

   Sleep(500)
   ControlClick($title, "", "[CLASS:TComboBox; INSTANCE:5]")
   Sleep(500)
   ControlSend($title, "", "[CLASS:TComboBox; INSTANCE:5]", "{DOWN}")
   Sleep(500)
   ControlClick($title, "", "[CLASS:TComboBox; INSTANCE:11]")
   Sleep(500)
   ControlSend($title, "", "[CLASS:TComboBox; INSTANCE:11]", "{UP}")
   Sleep(500)
EndFunc

Func WriteTCON()
   ControlClick($title, "", "[CLASS:TButton; INSTANCE:4]")
   Sleep(9000)
EndFunc

Func BackTCONToFile()
   ControlClick($title, "", "[CLASS:TButton; INSTANCE:3]")
   Sleep(5500)
   WinActivate($title)
   Sleep(300)
   Send("{ALT}")
   Send("FS")
   Sleep(3500) ; waiting for save diaglog
   ControlSetText($tSave, "", "[CLASS:Edit; INSTANCE:1]", @ScriptDir & "\" &"TEST_SAVE.bin")
   Sleep(700)
   ControlClick($tSave, "", "[CLASS:Button; INSTANCE:2]")
   Sleep(1000)
EndFunc

Func ExitProg()
   WinClose($title)
EndFunc


;Main Entry

If StringRight(@OSLang, 2) = 04 Then
  $tOpen="打开"
  $tSave="另保存"
EndIf

If $cmdline[0]<>1 Then
   MsgBox(64, "Usage", "LCD-FW.exe [-Check] | [-update]")
EndIf

Switch $cmdline[1]
   case "-check"
	  $ID=1
   case "-update"
	  $ID=2
   case Else
	  MsgBox (48, "Error", "Parameter is wrong")
	  MsgBox(64, "Usage", "LCD-FW.exe [-Check] | [-Update]")
	  exit (1)
EndSwitch

If $ID=1 Then
   Init()
;   ReadTCON()
   BackTCONToFile()
   ExitProg()
   Exit(0)
ElseIf $ID=2 Then
   Init()
   ReadTCON() ; Read first , avoid erase empty FW
   LoadBin()
   WriteTCON()
   BackTCONToFile()
   ExitProg()
   Exit(0)
EndIf

